import requests
from bs4 import BeautifulSoup

head = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.54'
}

def getcompulitylists(url):
    html = requests.get(url,headers=head).text
    soup = BeautifulSoup(html,'lxml')
    mylist = soup.select(".gl-i-wrap")
    for web in mylist:
        yield{
            "名字：": web.select("a em")[0].get_text(),
            "基本信息：": str(web.select("a i")[0].get_text()).replace("\n",""),
            "价格：": str(web.select("strong")[0].get_text()).replace("\n",""),
            "商店：": web.select("span a")[0].get_text()
        }

for i in range(1, 2):
    url = f"https://search.jd.com/Search?keyword=%E7%94%B5%E8%84%91%E7%AC%94%E8%AE%B0%E6%9C%AC&suggest=3&pvid=8977883040a04671a3c8a81f73de6017&page={i}"
    for item in getcompulitylists(url):
        print(item)
